import React, { Component } from 'react';
import { observer } from 'mobx-react';
import { Avatar, Tools } from 'weaver-mobile';
const getLabel = Tools.getLabel;
@observer
export default class ContactRemarkItem extends Component {
    constructor(props) {
        super(props);
        this.state = {
        }
    }

    render() {
       
        const { onReplyClick, sellChanceId, ContactAndRemarkStore, showBottom, onSaleManCardClick, onReplyRemind, data } = this.props;
        const { replyTime, replyDate, content, childReply, replyId, creater, rUser, remarktype, replyMainId, crmid } = data;
        const { departmentName, id, img, name, type, jobTitle, isUnder } = creater;
        return (
            <div className='crm-contact-reply-item' style={{ whiteSpace: "normal", wordBreak: " break-all" }}>
                {
                    remarktype == "remark" ?
                        <div className='crm-contact-reply-item-title'>
                             <span dangerouslySetInnerHTML={{ __html:  "<a class='crm_phone' onclick='javascript:window.openLink.openHrm("+id+");'>"+name + " :"+"</a>" }} />
                            {/* <a className='crm-contact-reply-item-commentator' onClick={(e) => { window.openLink.openHrm(id);e.stopPropagation(); }}>{name + " :"}</a> */}
                            <a dangerouslySetInnerHTML={{ __html: this.decode(content) }} onClick={(e) => { onReplyClick && onReplyClick({ workPlanId: replyMainId, parentId: replyId, receiver: id, customer: crmid }); e.stopPropagation(); }}></a>
                        </div>
                        :
                        <div className='crm-contact-reply-item-title'>
                            <span dangerouslySetInnerHTML={{ __html:  "<a class='crm_phone' onclick='javascript:window.openLink.openHrm("+id+");'>"+name +"</a>" }} />
                            {/* <a className='crm-contact-reply-item-commentator' onClick={(e) => { window.openLink.openHrm(id);e.stopPropagation(); }}>{name}</a> */}
                            <a className='crm-contact-reply-item-comment-action'>{getLabel(117, "回复")}&nbsp;</a>
                            <span dangerouslySetInnerHTML={{ __html:  "<a class='crm_phone' onclick='javascript:window.openLink.openHrm("+rUser.id+");'>"+rUser.name + " :"+"</a>" }} />
                            {/* <a className='crm-contact-reply-item-commentator' onClick={(e) => { window.openLink.openHrm(rUser.id);e.stopPropagation(); }}>{rUser.name + " :"}</a> */}
                            <a dangerouslySetInnerHTML={{ __html: this.decode(content) }} onClick={(e) => { onReplyClick && onReplyClick({ workPlanId: replyMainId, parentId: replyId, receiver: id, customer: crmid }); e.stopPropagation(); }}></a>
                        </div>
                }

                <div className='crm-contact-reply-item-row2'>
                    <div className='crm-contact-reply-item-row2-date'>
                        {replyDate}
                    </div>
                    <div className='crm-contact-reply-item-row2-time'>
                        {replyTime}
                    </div>
                    <div onClick={(e) => { onReplyClick && onReplyClick({ workPlanId: replyMainId, parentId: replyId, receiver: id, customer: crmid }); e.stopPropagation(); }} className='crm-contact-reply-item-row2-icon'>
                        <svg t="1573449253768" className="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4878" width="22" height="22">
                            <path d="M810.666667 213.333333a64 64 0 0 1 64 64v426.666667a64 64 0 0 1-64 64H478.336l-146.645333 96.106667A21.333333 21.333333 0 0 1 298.666667 846.250667V768h-85.333334a64 64 0 0 1-64-64V277.333333a64 64 0 0 1 64-64h597.333334z m0 64H213.333333v426.666667h149.333334v63.296L459.242667 704H810.666667V277.333333zM539.306667 490.666667v64H362.666667v-64h176.64zM661.333333 362.666667v64H362.666667v-64h298.666666z" p-id="4879" fill="#7478b5" />
                        </svg>
                    </div>
                </div>
            </div>
        )
    }
    //解码base64
    decode = (base64) => {
        return decodeURIComponent(atob(base64).split('').map(function (c) {
            return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
        }).join(''));
    }
}